package com.hdd.config;

import com.hdd.serviceImpl.TestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.remoting.rmi.RmiServiceExporter;
import service.TestService;

@Configuration
public class RMIService {

    @Autowired
    private Environment env;

    @Bean
    public RmiServiceExporter testService(TestServiceImpl testServiceImpl){
        RmiServiceExporter exporter = new RmiServiceExporter();
        exporter.setServiceName("testService");
        exporter.setServiceInterface(TestService.class);
        exporter.setService( testServiceImpl);
        exporter.setRegistryPort(env.getProperty("rmi.registryPort",Integer.class));
        exporter.setServicePort(env.getProperty("rmi.servicePort",Integer.class));
        return  exporter;
    }
}
